#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtGui>
#include "imageprocesser.h"
#include "labelmanager.h"
#include "imageviewport.h"




class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    void keyPressEvent(QKeyEvent *event);
    ~MainWindow();

public slots:
    void OpenImage();
    void SaveImageDialog();
    void Identify();
    void ZoomOut();
    void ZoomIn();

    void Tag();

    void UpdateViewport();
    void UpdateStatusBar();

    void EnableIdentify(bool val);
    void EnableSave(bool val);

    void OpenPreferences();
    void OpenInstructions();


signals:
    void Loaded(bool val);
    void Labeled(bool val);

private:
    void CreateMenus();
    void CreateActions();
    void CreateToolBars();
    void CreateStatusBar();
    bool LoadImage(QString path);
    bool SaveImage(QString path);
    void ScaleImage(float factor);
    void AdjustScrollBar(QScrollBar *scrollBar, double factor);


    ImageViewport *imageViewer;
    QScrollArea *scrollArea;
    QImage *originalImage;
    QImage *labeledImage;

    QLabel *statusBarLabel;

    int width;
    int height;
    QMenu *fileMenu;
    QMenu *toolsMenu;
    QMenu *helpMenu;
    QToolBar *toolBar;
    QAction *openImageAction;
    QAction *saveImageAction;
    QAction *identifyAction;
    QAction *zoomInAction;
    QAction *zoomOutAction;
    QAction *preferencesAction;
    QAction *quitAction;
    QAction *instructionsAction;

    ImageProcesser *proc;
    LabelManager labelManager;

    QAction *tagAction;
    QAction *removeLabelAction;

    float scaleFactor;
    bool labeled;
    bool loaded;

    unsigned char threshold;
    unsigned char erodeSize;
    unsigned char dilateSize;


};

#endif // MAINWINDOW_H
